<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
<#include "head.ftl" />
</head>
<body>
	<div class="body-box">
		<div class="rhead">
			<div class="rpos">当前位置: 商品库管理 - 编辑</div>
			<form class="ropt">
				<input type="button" value="返回"
					onclick="location.href='${st.domain}/goods/list'" />
			</form>
			<div class="clear"></div>
		</div>
		<form method="post" action="${st.domain}/goods/addOrEditDo" id="jvForm">
			<table width="100%" class="pn-ftable" cellpadding="2" cellspacing="1"
				border="0">
				<tr>
					<td width="10%" class="pn-flabel pn-flabel-h"><span
						class="pn-frequired">*</span>商品名称:</td>
					<td colspan="1" class="pn-fcontent"><input
						type="text" value="${goods.name}" name="name" class="required"
						size="25" maxlength="150" />
					</td>
				</tr>
				<tr>
					<td width="10%" class="pn-flabel pn-flabel-h"><span
						class="pn-frequired">*</span>关键字:</td>
					<td colspan="1" class="pn-fcontent"><input
						type="text" value="${goods.keywords}" name="keywords" class="required"
						size="25" maxlength="50" />
					</td>
				</tr>
				<tr>
					<td class="pn-flabel pn-flabel-h"><span
						class="pn-frequired">*</span>类别:
					<input type="hidden" id="catId_1" name="categoryByCatId.catId" value="${goods.categoryByCatId.catId}">
					<input type="hidden" id="catId_2" name="categoryByCatId2.catId" value="${goods.categoryByCatId2.catId}">
					</td>
					<td colspan="1" class="pn-fcontent" id="catSelectContent"></td>
				</tr>
				<tr>
					<td class="pn-flabel pn-flabel-h"><span
						class="pn-frequired">*</span>默认价格:</td>
					<td colspan="1" class="pn-fcontent"><input
						type="text" value="${goods.price}" name="price"
						class="required" maxlength="20" />
					</td>
					
				</tr>
				<tr>
					<td class="pn-flabel pn-flabel-h"><span
						class="pn-frequired">*</span>计费单位:</td>
					<td colspan="1" width="30%" class="pn-fcontent"><input
						type="text" value="${goods.unit}" name="unit"
						class="required" maxlength="20" />
					</td>
				</tr>
				<tr>
					<td class="pn-flabel pn-flabel-h"><span
						class="pn-frequired">*</span>购买单位:</td>
					<td colspan="1" width="30%" class="pn-fcontent"><input
						type="text" value="${goods.buyUnit}" name="buyUnit"
						class="required" maxlength="20" />
						每购买单位约为<input
						type="text" value="${goods.buyUnitMin}" name="buyUnitMin"
						class="required" maxlength="20" style="width:50px;"/>~
						<input
						type="text" value="${goods.buyUnitMax}" name="buyUnitMax"
						class="required" maxlength="20" style="width:50px;"/>
						<span>个计费单位</span>
					</td>
				</tr>
				<tr>
					<td class="pn-flabel pn-flabel-h"><span
						class="pn-frequired">*</span>最小购买量:</td>
					<td colspan="1" class="pn-fcontent"><input
						type="text" value="${goods.buyMin}" name="buyMin"
						class="required" maxlength="20" />
					</td>
					
				</tr>
				<tr>
					<td class="pn-flabel pn-flabel-h"><span
						class="pn-frequired">*</span>默认购买量:</td>
					<td colspan="1" class="pn-fcontent"><input
						type="text" value="${goods.buyDef}" name="buyDef"
						class="required" maxlength="20" />
					</td>
					
				</tr>
				<tr>
					<td class="pn-flabel pn-flabel-h"><span
						class="pn-frequired">*</span>加减幅度:</td>
					<td colspan="1" class="pn-fcontent"><input
						type="text" value="${goods.buyExt}" name="buyExt"
						class="required" maxlength="20" />
					</td>
					
				</tr>
				<tr>
					<td width="10%" class="pn-flabel pn-flabel-h"><span
						class="pn-frequired">*</span>图片:</td>
					<td colspan="1" width="30%" class="pn-fcontent"><input
						type="text" id="pic" value="${goods.pic}" name="pic"
						class="required" style="width:250px;"/><br><br>
						<img id="imgPrev" src="${goods.pic}" class="atta thumbImage">
						<input type="button" id="picFileBt" value="选择图片">
					</td>
				</tr>
				<tr>
					<td class="pn-flabel pn-flabel-h">商品介绍:</td>
					<td colspan="1" class="pn-fcontent"><textarea
							cols="40" rows="4" name="descrDef" maxlength="255">${goods.descrDef}</textarea>
					</td>
				</tr>
				<tr>
					<td colspan="4" class="pn-fbutton">
						<input type="hidden" name="goodsId" value="${goods.goodsId}" />
						<input type="hidden" name="id" value="1" /> <input type="submit" value="提交" /> &nbsp; 
						<input type="reset" value="重置" />
					</td>
				</tr>
			</table>
		</form>
	</div>
	<script>
	
	$("img.atta").each(function(index, el) {
		var src = $(el).attr("src");
		if (src.indexOf("http") == -1) {
			$(el).attr("src", g_domain  + src);
		}
		
	});
	
	$("#pic").keyup(function() {
		if ($(this).val().indexOf("http") == -1) {
			$("#imgPrev").attr("src", g_domain + $(this).val());
		}
	});
	
	// 显示分类下拉列表
	var defValue = $("#catId_2").val()?$("#catId_2").val():$("#catId_1").val();
	$("#catSelectContent").categoryComboBox({
		value: defValue,
		onSelect: function(deep, category) {
			$("#catId_" + deep).val(category?category.catId:"");
		}
	});
	
	var finder = new CKFinder();
	finder.resourceType = 'Images';
	finder.selectActionData = "container";
	finder.selectActionFunction = function(fileUrl, data) {
		$("#pic").val(fileUrl);
		$("#imgPrev").attr("src",g_domain  + fileUrl);
		
	};
	
	// 选择图片
	$("#picFileBt").click(function() {
		finder.popup();
	});
	
	</script>
</body>
</html>